package com.heyqing.topic.ArrangeCoins_0441;

/**
 * ClassName:ArrangeCoins
 * Package:com.heyqing.topic.ArrangeCoins_0441
 * Description:
 *
 * @Date:2024/9/29
 * @Author:Heyqing
 */
public class ArrangeCoins {
    public int arrangeCoins(int n) {
        int sn = 2 * n;
        for (int i = 0; i < n; i++) {
            if (i*i + i <= sn && (i+1)*(i+1) + (i+1) > sn) return i;
        }
        return n;
    }
}
